home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 8.5 KB | 272 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1993-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: AutoDialogAIQ New
- #
- # Version: 2.1.4
- # Description:
- # Contains two tasks from KTA that select menu items ending
- # in "...", then dismiss the dialogs that appear as a result.
- # Contains:
- # DialogButtonDismisser()
- # AutoDialog()
- #
- # History:
- # Date: By: Changes:
- # 07/23/93 KTA Created
- # 08/05/95 SBR Added Apple Copyright header for Radar 1273925
- # 09/27/96 BRL Added SPEC Exception handling
- # 01/30/97 SBR Deleted older exception code and comments.
- # 01/30/97 SBR Added an explicit script object.
- #
- #########################################################################
- #########################################################################
-
- Libraries
- # SPEC libraries
- "Globals.Lib",
- "UserInterface.Lib",
- "OutPut.Lib",
- "Misc.Lib",
- "ExceptionHandling.lib";
-
-
- script AutoDialogScript()
- begin
- AutoDialog();
- end;
-
-
- ########################################################################
- # DialogButtonDismisser()
- #=======================================================================
- # Author: KTA
- # Description: This routine will attempt to dismiss dialogs. This routine was
- # created to handle several types of dialogs that are handled in other
- # library routines. (1) Dialogs with title bars. (2) dialogs that
- # Do not contain 'Cancel' or 'OK' buttons.
- # Parameters: windOrd: the ordinality of the window to dismiss
- # Returns: nada
- #=======================================================================
- # History:
- # 07/27/93 KTA Created
- # 09/27/96 BRL Added SPEC Exception handling
- ########################################################################
- Task DialogButtonDismisser(windOrd := 1)
- begin
- dialogWind := FindWindow([window o:windOrd (*c:False*)]!);
- if not(dialogWind)
- dialogWind := FindWindow([window o:windOrd s:Dialog]!);
- while (dialogWind) # DoubleCheck to insure no dialog exists
- begin
- SpecialKey(EscapeKey, "Escape Key"); # try cancelling through Escape key if available
- newFrontWindow := findWindow(dialogWind);
- newFrontWindowRect := newFrontWindow.r;
- if((newFrontWindow) and (newFrontWindowRect = dialogWind.rect)) # window still exists at identical position
- begin
-
- if (_MatchBoolean([button t:'Cancel'], true))
- selectButton('Cancel');
- else if (_MatchBoolean([button t:'Done'], true))
- selectButton('Done');
- else if (_MatchBoolean([button t:'OK'], true))
- selectButton('OK');
- else if (_MatchBoolean([button t:'No'], true))
- selectButton('No');
- else if (_MatchBoolean([button t:'Yes'], true))
- selectButton('Yes');
- else
- begin
- SpecialKey(ReturnKey, "Return Key"); # try Okaying through Return key if available
-
- try
- newFrontWindow := match[window o:windOrd r:?newFrontWindowRect]!;
- catch theError
- begin
- if theError<>-1105
- ExceptionDispatcher(theError,,{"Match 1 in DialogButtonDismisser", {windOrd}});
-
- newFrontWindow :=[];
- end;
-
- if((newFrontWindow) and (newFrontWindowRect = dialogWind.rect)) # window still exists at identical position
- begin
- CenterofRectClick(); # try Dismissing by clicking in the center of the screen
-
- try
- newFrontWindow := match[window o:windOrd r:?newFrontWindowRect]!;
- catch theError
- begin
- if theError<>-1105
- ExceptionDispatcher(theError,,{"Match 2 in DialogButtonDismisser", {windOrd}});
-
- newFrontWindow :=[];
- end;
-
- if((newFrontWindow) and (newFrontWindowRect = dialogWind.rect)) # window still exists at identical position
- begin
- availableButtons := _Collect([button e:True w:1], true);
-
- if( availableButtons )
- begin
- #pick a button randomly
- #thisButton := AvailableButtons[random(1, card AvailableButtons)];
- #pick button 2 (standard Cancel)
- thisButton := AvailableButtons[2];
- buttonTitle := thisButton.t;
-
- _Select([Button t:buttonTitle]);
- LogStr("Selected the button titled '{buttonTitle}'");
-
- try
- newFrontWindow := match[window o:windOrd r:?newFrontWindowRect]!;
- catch theError
- begin
- if theError<>-1105
- ExceptionDispatcher(theError,,{"Match 3 in DialogButtonDismisser", {windOrd}});
-
- newFrontWindow :=[];
- end;
-
- if((newFrontWindow) and (newFrontWindowRect = dialogWind.rect)) # window still exists at identical position
- begin
- # pick button 1 (standard OK)
- thisButton := AvailableButtons[1];
- buttonTitle := thisButton.t;
-
- _Select([Button t:buttonTitle]);
- LogStr("Selected the button titled '{buttonTitle}'");
-
- end;
- end;
-
- try
- newFrontWindow := match[window o:windOrd r:?newFrontWindowRect]!;
- catch theError
- begin
- if theError<>-1105
- ExceptionDispatcher(theError,,{"Match 4 in DialogButtonDismisser", {windOrd}});
-
- newFrontWindow :=[];
- end;
-
- if((newFrontWindow) and (newFrontWindowRect = dialogWind.rect)) # window still exists at identical position
- begin
-
- _Close([window o:windOrd c:true], true);
- LogStr("Selected the close box");
- end;
- else
- # Give up if no buttons that VU can see
- begin
- LogStr("Unable to get rid of frontmost dialog, Aborting…");
- #Exit;
- return 0;
- end; #else
- end;
- end;
- end; #if
- end;
- wait(2);
- dialogWind := findWindow(dialogWind);
- end;
- end;
-
- ########################################################################
- # AutoDialog(specifiedMenu)
- #=======================================================================
- # Author: KTA
- # Description: This routine will match menuItems that end in '…' or '...'.
- # This should indicate that the menuitem will bring up a dialog
- # When selected.
- # Currently the dialog will be dismissed after it appears.
- # Parameters: specifiedMenu - 'String' - Menu to test
- # Note: Default is to do all menus.
- # Returns: nada
- #=======================================================================
- # History:
- # 07/27/93 KTA Created
- # 09/27/96 BRL Added SPEC Exception handling
- ########################################################################
- Task AutoDialog(specifiedMenu := '')
- begin
- global gWindListBegin;
-
- InitGlobals();
-
- gWindListBegin := {};
-
- tempWindList := _Collect([window]);
-
- for each tempWind in tempWindList
- gWindListBegin := gWindListBegin + {[window t:tempWind.t r:tempWind.r]};
-
-
- if(specifiedMenu)
- begin
- ### Collect all menuItems in menu <specifiedMenu> that end in '…' or '...'
- DialogMenuItemList := _Collect([menuitem t:/≈.../ e:true m:[menu t:specifiedMenu]]) +
- _Collect([menuitem t:/≈…/ e:true m:[menu t:specifiedMenu]]);
- end;
- else
- begin
- ### Collect all menuItems that end in '…' or '...'
- DialogMenuItemList := _Collect([menuitem t:/≈.../ e:true ]) +
- _Collect([menuitem t:/≈…/ e:true ]);
- end;
-
-
- ### Select the menuItems <Do the IVY Thang> and dismiss the dialogs
- println "============ Starting AutoDialog Testing =============";
- println; println;
- for each DialogMenuItem in DialogMenuItemList
- begin
- if (DialogMenuItem.e and not ((*DialogMenuItem.o = 1 and*) DialogMenuItem.m.o = 1))
- begin
- ### Select the menuitem that will bring up a dialog
-
- _Select(DialogMenuItem, true);
-
- wait(2);
-
- windListNow := {};
-
- tempWindList := _Collect([window]);
-
- for each tempWind in tempWindList
- windListNow := windListNow + {[window t:tempWind.t r:tempWind.r]};
-
- x := card windListNow; # x = how ever many windows there are
-
- for i := 1 to x begin
- currentWind := windListNow[i]; # currentWind := first item in list of windows up now
-
- if not isMember(currentWind, gWindListBegin) begin ## not working
- theNewWindow := currentWind;
- i := x + 1;
- end;
-
- end;
-
- theNewWindow := _Match(theNewWindow);
-
- theMenuTitle := DialogMenuItem.t;
- LogStr( "-------- Selected the menuitem - '{theMenuTitle}' - it should bring up a dialog ------");
-
- if (global gIVYHook)
- Call (gIVYHook);
-
- ### Dismiss the dialog
- wait(2); # Give Dialog time to appear
- #if not(DialogHandler())
- DialogButtonDismisser(theNewWindow.o);
- println;
- end;
- end;
- end;
-
-